<template>
<el-main>
   <div class="block">
    
    <!-- 信息列表 -->
    <el-descriptions class="margin-top" title="商家信息"  size="medium" border style="color: rgb(96,98,102);margin-top: 40px;">
      <el-descriptions-item>
        <template slot="label">
          <i class="el-icon-s-custom"></i>
          商户名称
        </template>
        {{merchant.name}}
      </el-descriptions-item>
      
      <el-descriptions-item>
        <template slot="label">
          <i class="el-icon-info"></i>
          商户介绍
        </template>
        {{merchant.detail}}
      </el-descriptions-item>
     
      <el-descriptions-item>
        <template slot="label">
          <i class="el-icon-question"></i>
          账号状态&nbsp;&nbsp;&nbsp;
          <span v-if="merchant.status==0" style="color:grey"><b>待审核</b></span>
          <span v-if="merchant.status==1" style="color:green"><b>已启用</b></span>
          <span v-if="merchant.status==2" style="color:red"><b>已拒绝</b></span>
        </template>      
      </el-descriptions-item>
      
    </el-descriptions>
    <br>
    <span>我的资质</span>
        <div >
      <img width="250" :src="merchant.charter">
      <br><br><br>
      <span >上传资质(只能上传jpg/png文件)</span><br>
  <div style=" margin-top:30px; margin-left:50px" v-loading="loading" >
    <el-upload 
    style="width:100px"
      class="upload-demo"
      name="files"
      drag
      action="http://localhost:8080/oos/upload/img/charter"
      :before-upload="beforeAvatarUpload"
      :on-success="handleSuccess"
      :limit="1"
      :show-file-list="false">
      <i class="el-icon-upload"></i>
      <div class="el-upload__text">将文件拖到此处，或<em>点击上传</em>
      </div>
      <!-- <div class="el-upload__tip" slot="tip">只能上传jpg/png文件，且不超过500kb</div> -->
    </el-upload>
  </div>
    <!-- <img src="" width="200px" id="img"> -->
    <img width="95" :src="imgsrc" >
    <!-- <br> -->

    <!-- 选择类型 -->
    </div>
  </div>
</el-main>
 
</template>

<script>
  export default {
    data() {
      return {
        merchant:{
            id:"",
            uid:"",
            name:"",
            detail:"",
            status:"",
            charter:""
        },
         loading: false,
      }
  

    },
    methods: {
       beforeAvatarUpload: function(){
        this.loading = true;
      },
      handleSuccess: function(response){
        if(response.status == "SUCCESS"){   
          this.merchant.charter=response.data[0]
           this.loading = false;
            this.$axios.post("http://localhost:8080/merchant/uploadcharter",
            response.data[0],{headers:{'Content-Type':'text/plain'}}).then(res=>{
        if(res.data.status=="SUCCESS"){
            alert("上传成功")
        }
      })
          return
        }
        else{
          this.loading = false;
          this.$message.error("文件上传失败")
        }
      }
    },
    mounted() {
      this.$axios.get("http://localhost:8080/merchant/findmerchant/"+JSON.parse(window.sessionStorage.getItem("user")).id).then(res =>{
         console.log(res.data)
        console.log(res.data.data)     
        this.merchant = res.data.data
      })
    }
  }
</script>

<style scoped>

</style>